local shifeng = fk.CreateSkill {
  name = "emo__shifeng",
}

shifeng:addEffect(fk.EventPhaseStart, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(shifeng.name) and target == player and player.phase == Player.Start then
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = table.filter(player.room.draw_pile, function(id)
      local card = Fk:getCardById(id)
      return card.type == Card.TypeEquip and #player:getAvailableEquipSlots(card.sub_type) > 0
        and player:canUseTo(card, player)
    end)
    if #cards == 0 then return end
    local cid = room:askToChooseCard(player, {
      target = player, skill_name = shifeng.name, prompt = "#emo__shifeng-card",
      flag = { card_data = { { shifeng.name, table.random(cards, 4)} } }
    })
    local card = Fk:getCardById(cid)
    room:useCard({
      from = player,
      tos = {player},
      card = card,
    })
    if card.sub_type == Card.SubtypeWeapon and not player.dead then
      room:askToUseVirtualCard(player, {
        name = "slash", skill_name = shifeng.name, extra_data = {bypass_distances = true}
      })
    end
  end,
})


Fk:loadTranslationTable{
  ["emo__shifeng"] = "试锋",
  [":emo__shifeng"] = "准备阶段，你可以从牌堆四张装备牌中选择并使用一张，若此牌为武器牌，你可以视为使用一张【杀】。",
  ["#emo__shifeng-card"] = "试锋：选择并使用其中一张",
}


return shifeng
